package com.woniuxy.warehouse.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.commons.entity.warehouse.IoWarehouse;
import com.woniuxy.commons.entity.warehouse.dto.StockInHomePageDto;
import com.woniuxy.commons.entity.warehouse.dto.TimeAndOrderDto;
import com.woniuxy.commons.result.Result;
import com.woniuxy.warehouse.mapper.StockInHomePageDao;
import com.woniuxy.warehouse.service.StockInHomePageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author:SHEAndme
 * @Todo:TODO
 * @DateTime:2022/4/25 14:15
 * @Component:霍格沃兹魔法学院
 **/
@Service
public class StockInHomePageImpl implements StockInHomePageService {
    @Resource
    private StockInHomePageDao stockInHomePageDao;
    @Override
    public Result findAllStockInHomePage(Integer currentPage, Integer pageSize, TimeAndOrderDto timeAndOrderDto) {
        PageHelper.startPage(currentPage,pageSize);
        List<StockInHomePageDto> timeAndOrderDtoList = stockInHomePageDao.findAll(timeAndOrderDto);

        PageInfo<StockInHomePageDto> of = PageInfo.of(timeAndOrderDtoList);
        System.out.println(of);
        Result<PageInfo> listResult = new Result<>();
        if(timeAndOrderDtoList.size()>0){
            listResult.setData(of);
            listResult.setCode(200);
            listResult.setMessage("查询成功");
        }else {
            listResult.setData(null);
            listResult.setCode(500);
            listResult.setMessage("数据为空");
        }
        return listResult;
    }
}
